using System;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using common;

public class item_base
{
    private static readonly string data_path = "item_base.XML";
    public static Dictionary<int, item_base> datas = null;// = new Dictionary<int, item_base>();

	private short m_id = 0;
    public short id { get { return m_id; } }

    private short m_type = 0;
    public short type { get { return m_type; } }

    private string m_name = "";
    public string name { get { return m_name; } }

    private string m_icon_path = "";
    public string icon_path { get { return m_icon_path; } }


	public static void Load()
	{
        if (datas == null)
        {
            datas = new Dictionary<int, item_base>();
        }
        else return;

        Dictionary<int, Dictionary<string, string>> result = FileSurport.parseXML(data_path);

        foreach (var item_s in result)
        {
            var item = new item_base();
            item.init(item_s.Value);
            datas[item_s.Key] = item;
        }
        return;
	}

    public void init(Dictionary<string,string> resource)
    {
        m_id = Convert.ToInt16(resource["item_id"]);
        m_type = Convert.ToInt16(resource["item_type"]);
        m_name = Convert.ToString(resource["name"]);
        m_icon_path = Convert.ToString(resource["icon_path"]);
    }
} 
